<?php
//start session, local variables, ect.
include('includes/init.php');

if(!$_SESSION['display_colors'])
	$_SESSION['display_colors']=false;

if($_POST['colors']=='on')
	$_SESSION['display_colors']=true;
elseif($_POST['colors']=='off')
	$_SESSION['display_colors']=false;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html style="margin: 0px; height: 100%;">
<head>
<meta http-equiv="content-type" content="text/html; charset=<?echo($conf['html_character_set']);?>" />
<link rel="stylesheet" href="<?echo($GLOBALS['theme_path']);?>css.css" type="text/css" />
<link rel="stylesheet" href="<?echo($GLOBALS['theme_path']);?>basic.css" type="text/css" />
<title><?echo($lang['help_help']);?></title>
</head>
<body onload="init();" style="margin: 0px; height: 100%;" class="tabelka2">
<script type="text/javascript">
<!--
var ol_textfont = "Verdana";
var ol_fgcolor = "#FFFFFF";
var ol_bgcolor = "#000000";
var ol_textcolor = "#000000";
var ol_capcolor = "";
var ol_closecolor = "";
var ol_captionfont = "";
var ol_offsetx = 15;
var ol_offsety = 15;
var ol_vauto = 1;
var ol_hauto = 1;
-->
</script>
<div id="overdiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
<script type="text/javascript" src="java/overlib.js">
<!-- overlib (c) erik bosrup -->
</script>

<script type="text/javascript">
<!--
var source=opener.document.getElementById('<?echo($_GET['dom_id']);?>');
function init(){
<?if($_SESSION['display_colors']) {?>
	editor.setKeyBinding('joe');
	editor.setAutoIndent('on');
	<?if(!isset($_POST['preview'])) {?>
		var src_v=source.value.split("\n").join("\n ");
	<?} else {?>
		var src_v=document.getElementById('preview').value.split("\n").join("\n ");
	<?}?>
	editor.setContents(src_v);
<?} else {?>
	<?if(!isset($_POST['preview'])) {?>
		document.getElementById('text').value=source.value;
	<?} else {?>
		document.getElementById('text').value=document.getElementById('preview').value;
	<?}?>
<?}?>
}

<?php if(!$_SESSION['display_colors']) {?>
var curr_state_='wo_colors';
<?} else {?>
var curr_state_='colors';
<?}?>
function wo_colors() {
	if(curr_state_=='colors') {
		var src_v=editor.getContents();
		
		editor.inputLineEntry.blur();		
		src_v=src_v.split("\n ").join("\n");
		document.getElementById('text').value=src_v;
		curr_state_='wo_colors';
		
		return true;
	}
	
	return false;
}
//-->
</script>
<script type="text/javascript" src="java/jscript.js"></script>

<?if(!$_GET['cmd']) {?>
<div class="row_3" style="text-align: center; width: 100%;"><b><?echo($lang['help_help']);?></b></div>
<div class="row_2" style="width: 100%; height: 100%;">

<!--  preview output start //-->
<?if($_POST['preview']) {?><div style="padding: 20px;" class="tabelka2">
<?php
$_POST['text']=read_text_rest($_POST['text']);
if(!perms_check('admin', 'panel')) {
	echo(read_text_comments(post_text_comments($_POST['text'])));
	$_POST['text']=read_text_edit($_POST['text']);
} else {
	echo(read_text(post_text($_POST['text'])));
	$_POST['text']=read_text_edit($_POST['text']);
}
?></div><?}?>
<!--  preview output end //-->

<textarea style="display:none;" id="preview"><?echo($_POST['text']);?></textarea>

<!--  color / wo_color //-->
<div class="row_2" style="width: 100%; padding: 2px;"><span class="btn" style="margin-left: 41px;"><a href="#" onclick="javascript:document.getElementById('help_form').colors.value='on'; 	document.getElementById('help_form').submit();">Colors ON</a></span> <span class="btn"><a href="#"  onclick="javascript:document.getElementById('help_form').colors.value='off'; if(wo_colors()) {} document.getElementById('help_form').submit();">Colors OFF</a></span></div>

<!--  left //-->
<span id="colors" style="width: 80%; height: 90%; <?if(!$_SESSION['display_colors']){?>display: none;<?}?>"><iframe name="editor" src="java/sh/editor.html" frameborder="0" scrolling="auto" style="width: 80%; height: 90%; clear: both; float: left;  background-color: #FFFFFF;"></iframe></span>
<form action="<?echo($_SERVER['REQUEST_URI']);?>" method="post" style="height: 100%;" name="help_form" id="help_form"><input type="hidden" name="colors" value="" /><span id="wo_colors" style="<?if($_SESSION['display_colors']){?>display: none;<?}?> float: left; clear: both; width: 76%; height: 90%; margin-left: 41px;"><textarea class="button" name="text" id="text" style="width: 95%; height: 100%; clear: both; float: left;" wrap="off"></textarea></span>

<!--  right //--> 
<div style="float: left; width: 18%; height: 100%; margin-left: 5px;">
<input type="button" value="<?echo($lang['admin_add']);?>" onclick="javascript:if(wo_colors()) {} source.value=document.getElementById('text').value; opener.focus(); window.self.close();" class="button"> <input type="hidden" name="preview" value="preview" /> <input type="button" onclick="javascript:if(wo_colors()) {} document.help_form.submit();" value="<?echo($lang['admin_preview']);?>" class="button" />
<br /><br />
	<span id="wo_colors_controls" <?if($_SESSION['display_colors']){?>style="display: none;"<?}?>>
	<img src="<?echo($GLOBALS['theme_path'].$GLOBALS['theme_img']['image']);?>" onClick="return overlib('<iframe width=\'300\' height=\'300\' src=\'browse.php?form=parent.document.help_form.text&amp;cmd=image&amp;module=<?echo($_GET['module']);?>&amp;id=<?echo($_GET['id']);?>\' frameborder=\'0\'>', STICKY, CLOSECLICK, LEFT, WRAP, CELLPAD, 5, CAPTIONFONTCLASS, 'row_3', CLOSEFONTCLASS, 'row_3', CLOSETEXT, '<b><?echo($lang['close_window']);?></b>', CLOSETITLE, '<?echo($lang['close_window']);?>', CAPTION, '<b>&nbsp;&nbsp;&amp;nbsp;<?echo($lang['admin_browse']);?></b>');" alt="<?echo($lang['image_insert']);?>" title="<?echo($lang['image_insert']);?>" />&nbsp;
	<img src="<?echo($GLOBALS['theme_path'].$GLOBALS['theme_img']['upload']);?>" onClick="return overlib('<iframe width=\'460\' height=\'400\' src=\'images_upload.php?module=<?echo($_GET['module']);?>&amp;id={id}\' frameborder=\'0\'>', STICKY, CLOSECLICK, LEFT, WRAP, CELLPAD, 5, CAPTIONFONTCLASS, 'row_3', CLOSEFONTCLASS, 'row_3', CLOSETEXT, '<b><?echo($lang['close_window']);?></b>', CLOSETITLE, '<?echo($lang['close_window']);?>', CAPTION, '<b>&nbsp;&nbsp;&amp;nbsp;<?echo($lang['images_upload']);?></b>');" alt="<?echo($lang['images_upload']);?>" title="<?echo($lang['images_upload']);?>" />&nbsp;
	<img src="<?echo($GLOBALS['theme_path'].$GLOBALS['theme_img']['url']);?>" onClick="return overlib('<IFRAME WIDTH=\'300\' HEIGHT=\'150\' SRC=\'help.php?cmd=help&amp;tag=urls&amp;tag_form=parent.document.help_form.text\' FRAMEBORDER=\'0\'>', STICKY, CLOSECLICK, LEFT, WRAP, CELLPAD, 5, CAPTIONFONTCLASS, 'row_3', CLOSEFONTCLASS, 'row_3', CLOSETEXT, '<b><?echo($lang['close_window']);?></b>', CLOSETITLE, '<?echo($lang['close_window']);?>', CAPTION, '<b>&nbsp;&nbsp;&amp;nbsp;<?echo($lang['help_help']);?></b>');" alt="<?echo($lang['insert_url']);?>" title="<?echo($lang['insert_url']);?>" />
	
	<br />
	<?echo(get_exbcode_buttons('document.getElementById(\'text\')'));?>
	<br />
	
	<img src="<?echo($GLOBALS['theme_path'].$GLOBALS['theme_img']['expand']);?>" onclick="chngds('exbcode_others');" />
	<span style="display: none;" id="exbcode_others"><?get_exbcode('document.getElementById(\'text\')', 'echo');?></span>	
	
	</span><br /><br /><input type="button" value="<?echo($lang['close_window']);?>" onclick="javascript: if(window.confirm('<?echo(string_template($lang['admin_really'], array('yes'=>'', 'no'=>'')));?>')) window.self.close();" class="button" />
</form>

</div>

<?php
 }
else {
?>
<form name="help" action="help.php" method="post">
<table align="center" width="100%" border="0" class="tabelka2">
<tr valign="top">
   <td><select name="sel" class="button">
   <?plugins('std/help/1/');?>
   </select>&nbsp;<input type="button" class="button" onclick="javascript:location.href='help.php?cmd=help&amp;tag=urls&amp;language=<?echo($_GET['language']);?>&amp;tag_form=<?echo($_GET['tag_form']);?>&amp;sel='+this.form.sel.options[this.form.sel.selectedIndex].value+'';" value="<?echo($lang['select']);?>" /></td>
</tr>
<tr valign="top">
   <td>
<?php
if(in_array($_GET['sel'], array('article', 'download', 'news', 'pages'))) {
	if(!$_GET['language'] or !in_array($_GET['language'], get_lang_list())) $_GET['language']=$_SESSION['lang_short'];
  
    $db = new dbquery;
    
	$GLOBALS['options']='';
	$db->query("SELECT * FROM $conf[prefix]$_GET[sel] ORDER by id DESC") or $db->err(__FILE__, __LINE__);
	while($d=$db->fetch_object()) {
		plugins('std/help/2/');
	}
?>
<select name="hlp" class="button"><?echo($GLOBALS['options']);?></select>
<br /><input type="text" name="s_hlp" size="10" class="button" onkeyup="javascript:findInSelect(this.form.s_hlp.value, this.form.hlp, 1);" />
 <input type="button" class="button" value="<?echo($lang['admin_add']);?>" onclick="javascript:add_content('[<?echo($_GET['tag']);?>='+this.form.hlp.options[this.form.hlp.selectedIndex].value+']'+this.form.hlp.options[this.form.hlp.selectedIndex].text+'[/<?echo($_GET['tag']);?>]', <?echo($_GET['tag_form']);?>);" />
<?php } ?>
   </td>
</tr>
</table></form>
<?php
}
?>
</div>
   
</body>
</html>
